package garin.parse.sql.oracle;

import garin.parse.StringToken;
import garin.parse.Token;

public class OracleString extends StringToken {
	private boolean init = true;
	
	protected OracleString(final Token source, final String open) {
		super(source, open);
		ignore = "q'".equals(open) ? 2 : 3;
	}
	
	@Override
	public Token on() throws Exception {
		if (ignore > 0) {
			ignore--;
			return self();
		}
		if (init) {
			init = false;
			final char ch = is('[') ? ']' : is('{') ? '}' : is('<') ? '>'
					: is('(') ? ')' : ch();
			close = ch + "'";
		}
		return super.on();
	}
}
